package pk.sistema.vendas.web;

import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;

public class HibernateUtil {
	
	private static final SessionFactory sessao = buildSessionFactory();

	private static SessionFactory buildSessionFactory() {
	
		try {
			
			Configuration confg = new Configuration();
			confg.configure("hibernate.cfg.xml");
			
			return confg.buildSessionFactory();
		
		} catch (Throwable e) {
		
		System.out.println("Não Conectou!!!\n" + e);	
		
		throw new ExceptionInInitializerError();
		}
	
	}

	public static SessionFactory getSessao() {
		return sessao;
	}

}